// pages/orderDetails/orderDetails.js
var common = require("../../utils/Conmon.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    UserName: '',
    Phone: '',
    Address: '',
    GetOrderDetails: {},
    YunMoney: 0,
    UseCardCoupons: 0,
    PayAmount: 0,
    OrderID: '',
    CreateTime: '',
    Remark: '',
    UsePoint: 0,
    UseMoney: 0,
    PayType: 0,
    UnionStoreName:"官方自营",
    StoreType: "自营",
    shopID:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    common.pageInit( function () {
    });
    wx.showLoading({
      title: '加载中...',
      mask: true
    });

    var that = this;
    that.setData({ shopID: options.shopID});
    var globalData = getApp().globalData;
    var custId = globalData.custID;
    var OrderId = options.OrderID;
    var url = globalData.apiurl + '/order/api/OrderInfo/GetOrderByOrderId';

    wx.request({
      url: url,
      data: { "custId": custId, "orderId": OrderId, "unionShopID": that.data.shopID },
      method: 'GET',
      header: {
        'content-type': 'application/json',
        'X_ManuName': globalData.manuName
      },
      success: function (res) {
        var OrderInfo = res.data.content;
        that.setData({
          UserName: OrderInfo.UserName,
          Phone: OrderInfo.Phone,
          Address: OrderInfo.Address,
          GetOrderDetails: OrderInfo.GetOrderDetails,
          YunMoney: OrderInfo.YunMoney,
          UseCardCoupons: OrderInfo.UseCardCoupons,
          PayAmount: OrderInfo.PayAmount,
          OrderID: OrderInfo.OrderID,
          CreateTime: OrderInfo.CreateTime,
          Remark: OrderInfo.Remark,
          UsePoint: OrderInfo.UsePoint,
          UseMoney: OrderInfo.UseMoney,
          PayType: OrderInfo.PayType,
          UnionStoreName: OrderInfo.UnionStoreID == 0 ? "官方自营" : OrderInfo.UnionShopName,
          StoreType: OrderInfo.UnionStoreID == 0 ? "自营" : "商家",
        })
        wx.hideLoading();
      },
      fail: function () {
        wx.hideLoading();
        wx.showToast({
          title: '获取订单详情失败',
          duration: 2000
        })
      },
      complete: function () {
        //complete
      }
    })  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})